﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;
using System.Threading;
using System.Windows.Markup;
using System.Globalization;
using System.Diagnostics.Contracts;

namespace wzSqlAdmin
{
    public class Localizer : INotifyPropertyChanged { 
        public Localizer() 
        { 
            Culture = Thread.CurrentThread.CurrentCulture; 
        } 
        XmlLanguage _language; 
        public XmlLanguage Language 
        { 
            get { return _language; 
            } 
            private set {
                _language = value;
                NotifyPropertyChanged("Language");
            } 
        } 
        CultureInfo _culture; 
        public CultureInfo Culture { 
            get { 
                return _culture;
            } 
            set { 
                Contract.Requires(value != null); 
                if (_culture == value) return; 
                _culture = value; 
                Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = value; 
                Language = XmlLanguage.GetLanguage(value.Name);
                NotifyPropertyChanged("Culture"); 
            } 
        }
        protected void NotifyPropertyChanged(string propName) 
        { 
            var e = PropertyChanged; 
            if (e != null) e(this, new PropertyChangedEventArgs(propName));
        }
        public event PropertyChangedEventHandler PropertyChanged;
    }
 }
